<template>
    <div class="content">
        <div class="icon">
            <i class="iconfont icon-fangwufangchan"></i>
        </div>
        <div class="right">
            <div class="number">
                <span>{{ state.number }}</span>
            </div>
            <div class="introduce">房屋总数</div>
        </div>
    </div>
</template>

<script>
import getApi from '@/api/getApi';
import { onMounted, reactive } from 'vue';
export default {
    setup () {
        const state = reactive({
            number:null
        })
        onMounted(()=>{
            getNumber()
        })
        // 读取缓存
        const getCookie = (cname) => {   // 参数为存储名
            var name = cname + "=";
            var ca = document.cookie.split(';');
            for (var i = 0; i < ca.length; i++) {
                var c = ca[i].trim();
                if (c.indexOf(name) == 0) return decodeURIComponent(c.substring(name.length, c.length));
            }
            return "";
        };
        // 获取房屋总数数据
        const getNumber = () =>{
            let obj = {Authorization:getCookie('token')}
            getApi('/roomhead/getRoomCount','post',{},obj).then((res)=>{
                // console.log(res)
                state.number = res.data.data
            })
        }

        return {state}
    }
}
</script>

<style lang="less" scoped>
    .content{
        height: 100%;
        display:flex;
        justify-content: space-around;
        align-items: center;

        .icon{
            height: 50px;
            width: 50px;
            background-color: rgb(206, 233, 254);
            border-radius: 50%;
            line-height: 50px;
            text-align: center;
            
            i{
                color: rgb(10, 146, 250);
                font-size: 30px;
            }
        }
        .right{
            span{
                font-size: 22px;
                font-weight: bold;
            }
            .introduce{
                font-size: 12px;
                color: rgb(172, 172, 172);
            }
        }
    }
</style>